<template>
	<view v-if="show">
		<slot />
	</view>
</template>

<script>
	export default {
		name: "showButton",
		data() {
			return {
				show: false
			}
		},
		props: {
			action: {
				type: String,
				default: ''
			}
		},
		created() {
			const pages = getCurrentPages();
			this.show = this.getBtnShow(pages[0].route, this.action)
		},
		methods: {
			getBtnShow(page, action) {
				let menuList = uni.getStorageSync('menuList')
				let obj1 = menuList.find(item => item.path === page)
				if (!obj1) return false
				let obj2 = obj1.subMenus.find(item => item.action === action)
				if (!obj2) return false
				return obj2.enabled == '1'
			}
		}

	}
</script>